/*
 * JVM_Native.c
 *
 *  Created on: 08.01.2011
 *      Author: Tavin
 */
#include <stdint.h>

#include "JVM_StatusCodes.h"

#include "JVM_CP_Method.h"
#include "JVM_Native.h"

#include "JVM_Console.h"
#include "JVM_String.h"
#include "JVM_Thread.h"
#include "JVM_Random.h"
#include "JVM_Keys.h"
#include "JVM_Display2D.h"
#include "JVM_Acc.h"
#include "JVM_Bitmap2D.h"
#include "JVM_led.h"


uint16_t (* JVM_StaticTable [0x70]) ()={JVM_Thread_sleep,				//0x00
										NULL,							//0x01
										JVM_String_valueOfFloat,		//0x02
										JVM_String_valueOfInt,			//0x03
										JVM_String_valueOfDouble,		//0x04
										NULL,							//0x05
										NULL,							//0x06
										NULL,							//0x07
										NULL,							//0x08
										NULL,							//0x09
										NULL,							//0x0A
										NULL,							//0x0B
										NULL,							//0x0C
										NULL,							//0x0D
										JVM_Random_get,					//0x0E
										JVM_Random_get_range,			//0x0F

										JVM_Console_putChar,			//0x10
										NULL,							//0x11
										NULL,							//0x12
										NULL,							//0x13
										NULL,							//0x14
										NULL,							//0x15
										NULL,							//0x16
										NULL,							//0x17
										NULL,							//0x18
										NULL,							//0x19
										NULL,							//0x1A
										NULL,							//0x1B
										NULL,							//0x1C
										NULL,							//0x1D
										NULL,							//0x1E
										NULL,							//0x1F

										JVM_LED_on,						//0x20
										JVM_LED_off,					//0x21
										JVM_LED_toggle,					//0x22
										NULL,							//0x23
										NULL,							//0x24
										NULL,							//0x25
										NULL,							//0x26
										NULL,							//0x27
										NULL,							//0x28
										NULL,							//0x29
										NULL,							//0x2A
										NULL,							//0x2B
										NULL,							//0x2C
										NULL,							//0x2D
										NULL,							//0x2E
										NULL,							//0x2F

										JVM_Keys_LUp,					//0x30
										JVM_Keys_LDown,					//0x31
										JVM_Keys_LLeft,					//0x32
										JVM_Keys_LRight,				//0x33
										JVM_Keys_RUp,					//0x34
										JVM_Keys_RDown,					//0x35
										JVM_Keys_RLeft,					//0x36
										JVM_Keys_RRight,				//0x37
										JVM_Keys_keyPressed,			//0x38
										JVM_Acc_getAxis,				//0x39
										NULL,			//0x3A
										NULL,			//0x3B
										NULL,			//0x3C
										NULL,			//0x3D
										NULL,			//0x3E
										NULL,			//0x3F

										// TODO: Display2D ab hier
										JVM_Display2D_setPixel,			//0x40
										JVM_Display2D_clear,			//0x41
										JVM_Display2D_setTopLED,		//0x42
										JVM_Display2D_rowCount,			//0x43
										JVM_Display2D_columCount,		//0x44
										JVM_Display2D_repaint,			//0x45
										JVM_Display2D_setSideLED,		//0x46
										JVM_Display2D_fillAll,			//0x47
										JVM_Display2D_print5x5Char,		//0x48
										JVM_Display2D_print8x8Char,		//0x49
										JVM_Display2D_dravLine,			//0x4A
										JVM_Display2D_display2DBitmap,	//0x4B
										NULL,							//0x4C
										NULL,							//0x4D
										NULL,							//0x4E
										NULL,							//0x4F

										NULL,				//0x50
										NULL,							//0x51
										NULL,							//0x52
										NULL,							//0x53
										NULL,							//0x54
										NULL,							//0x55
										NULL,							//0x56
										NULL,							//0x57
										NULL,							//0x58
										NULL,							//0x59
										NULL,							//0x5A
										NULL,							//0x5B
										NULL,							//0x5C
										NULL,							//0x5D
										NULL,							//0x5E
										NULL,							//0x5F

										JVM_Bitmap2D_fill,				//0x60
										JVM_Bitmap2D_setPixel,			//0x61
										JVM_Bitmap2D_getPixel,			//0x62
										JVM_Bitmap2D_drawLine,			//0x63
										JVM_Bitmap2D_mirror,			//0x64
										JVM_Bitmap2D_print5x5Char,		//0x65
										JVM_Bitmap2D_print8x8Char,		//0x66
										JVM_Bitmap2D_not,				//0x67
										JVM_Bitmap2D_min,				//0x68
										JVM_Bitmap2D_max,				//0x69
										NULL,							//0x6A
										NULL,							//0x6B
										NULL,							//0x6C
										NULL,							//0x6D
										NULL,							//0x6E
										NULL,							//0x6F



};



/****************************************************************************************/
/*																						*/
/*	Function : JVM_Native_executeStatic						Author : OG					*/
/*																						*/
/*	Description : 								   										*/
/*																						*/
/*	Version : 1.0					Date :2011.1.8			Status : Working   			*/
/*																						*/
/****************************************************************************************/
uint16_t JVM_Native_executeStatic(JVM_CP_Method_t * myMethodInfo)
{
uint16_t functionNumber;
uint16_t StatusCode;
JVM_Method_t *myMethod;

		myMethod=myMethodInfo->adress;

		functionNumber=myMethod->codeLenght;

		if (functionNumber>sizeof(JVM_StaticTable)/sizeof(void*))
			{
			//TODO unknown Function !!!!! ERROR !!!!

			}

		StatusCode=JVM_StaticTable[functionNumber] ();

	return (StatusCode);
}
